
import tkinter
import tkinter.constants as TKC
import tkinter.ttk as ttk
import time
import calendar
#from tkinter.constants import *

style = ttk.Style()
style.configure("day_header", width=20, foreground="black", background="white", relief=TKC.FLAT)


#Python handles time in a funny fashion

localtime = time.localtime()
current_year = localtime[0]
current_month = localtime[1]
current_date = localtime[2]
current_day = localtime[6]
days_in_current_month = calendar.monthrange(current_year, current_month)[1] #calendar.monthrange returns two values: the first day of the month AND the number of days in the month.
days_in_previous_month = calendar.monthrange(current_year, current_month)[1]

def columnOneDate(column):
    if current_day == 0: #Monday
        calendar_date =(current_date + column)
    elif current_day == 1: #Tuesday
        calendar_date = (current_date + (column -1))
    elif current_day == 2: #Wednesday
        calendar_date = (current_date + (column -2))
    elif current_day == 3: #Thursday
        calendar_date = (current_date + (column - 3))
    elif current_day == 4: #Friday
        calendar_date = (current_date + (column - 4))
    elif current_day == 5: #Saturday
        calendar_date = (current_date + (column - 5))
    elif current_day == 6: #Sunday
        calendar_date = (current_date + (column - 6))
    if calendar_date > days_in_current_month:
        return (calendar_date - days_in_current_month)
    elif calendar_date <1 and current_month !=0:
        return (calendar_date + days_in_previous_month)
    elif calendar_date <1 and current_month == 0:
        return (calendar_date + 31)
    else:
        return calendar_date



application = tkinter.Tk()
CALENDARFRAME = tkinter.Frame(application)
CALENDARFRAME.pack()


monday = tkinter.Label(CALENDARFRAME, text="Monday")
monday.grid(row = 0, column = 0,padx=15, pady=13)
tuesday = tkinter.Label(CALENDARFRAME, text="Tuesday")
tuesday.grid(row=0, column =1, padx=15, pady=13)
wednesday = tkinter.Label(CALENDARFRAME, text="Wednesday")
wednesday.grid(row=0, column=2, padx=15, pady=13)
thursday = tkinter.Label(CALENDARFRAME, text="Thursday")
thursday.grid(row=0, column =3, padx=15, pady=13)
friday = tkinter.Label(CALENDARFRAME, text="Friday")
friday.grid(row=0, column=4, padx=15, pady=13)
saturday = tkinter.Label(CALENDARFRAME, text="Saturday")
saturday.grid(row=0,column=5,padx=15, pady=13)
sunday = tkinter.Label(CALENDARFRAME, text="Sunday")
sunday.grid(row=0,column=6,padx=15, pady=13)

labelA0 = tkinter.Frame(CALENDARFRAME)
labelA0.grid(row=1,column=0)
labelA1 = tkinter.Frame(CALENDARFRAME)
labelA1.grid(row=1,column=1)
labelA2 = tkinter.Frame(CALENDARFRAME)
labelA2.grid(row=1,column=2)
labelA3 = tkinter.Frame(CALENDARFRAME)
labelA3.grid(row=1,column=3)
labelA4 = tkinter.Frame(CALENDARFRAME)
labelA4.grid(row=1,column=4)
labelA5 = tkinter.Frame(CALENDARFRAME)
labelA5.grid(row=1,column=5)
labelA6 = tkinter.Frame(CALENDARFRAME)
labelA6.grid(row=1,column=6)

labelB0 = tkinter.Frame(CALENDARFRAME)
labelB0.grid(row=2,column=0)
labelB1 = tkinter.Frame(CALENDARFRAME)
labelB1.grid(row=2,column=1)
labelB2 = tkinter.Frame(CALENDARFRAME)
labelB2.grid(row=2,column=2)
labelB3 = tkinter.Frame(CALENDARFRAME)
labelB3.grid(row=2,column=3)
labelB4 = tkinter.Frame(CALENDARFRAME)
labelB4.grid(row=2,column=4)
labelB5 = tkinter.Frame(CALENDARFRAME)
labelB5.grid(row=2,column=5)
labelB6 = tkinter.Frame(CALENDARFRAME)
labelB6.grid(row=2,column=6)

#######################Day Buttons##############################
ButtonA0 = ttk.Button(labelA0, style="day_header", text=columnOneDate(0))
ButtonA0.grid(row=1,column=0)
ButtonA1 = tkinter.Button(labelA1, text=columnOneDate(1))
ButtonA1.grid(row=1,column=1)
ButtonA2 = tkinter.Button(labelA2, relief=TKC.FLAT, text=columnOneDate(2))
ButtonA2.grid(row=1,column=2)
ButtonA3 = tkinter.Button(labelA3, relief=TKC.FLAT, text=columnOneDate(3))
ButtonA3.grid(row=1,column=3)
ButtonA4 = tkinter.Button(labelA4, relief=TKC.FLAT, text=columnOneDate(4))
ButtonA4.grid(row=1,column=4)
ButtonA5 = tkinter.Button(labelA5, relief=TKC.FLAT, text=columnOneDate(5))
ButtonA5.grid(row=1,column=5)
ButtonA6 = tkinter.Button(labelA6, relief=TKC.FLAT, text=columnOneDate(6))
ButtonA6.grid(row=1,column=6)

ButtonB0 = tkinter.Button(labelB0, width=20, text=columnOneDate(7))
ButtonB0.grid(row=1,column=0)
ButtonB1 = tkinter.Button(labelB1, relief=TKC.FLAT, text=columnOneDate(8))
ButtonB1.grid(row=1,column=1)
ButtonB2 = tkinter.Button(labelB2, relief=TKC.FLAT, text=columnOneDate(9))
ButtonB2.grid(row=1,column=2)
ButtonB3 = tkinter.Button(labelB3, relief=TKC.FLAT, text=columnOneDate(10))
ButtonB3.grid(row=1,column=3)
ButtonB4 = tkinter.Button(labelB4, relief=TKC.FLAT, text=columnOneDate(11))
ButtonB4.grid(row=1,column=4)
ButtonB5 = tkinter.Button(labelB5, relief=TKC.FLAT, text=columnOneDate(12))
ButtonB5.grid(row=1,column=5)
ButtonB6 = tkinter.Button(labelB6, relief=TKC.FLAT, text=columnOneDate(13))
ButtonB6.grid(row=1,column=6)
